<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div>
    <h1>工程首页</h1>
    <a href="/upload.html">上传图片</a>
    <hr>
    <div v-for="image in arr">
        <h2>{{image.intro}}</h2>
        <!--/a.jpg,/b.jpg,/c.jpg-->
        <!--此时image对象中有一个urlArr数组装着多个图片的路径 遍历添加图片标签-->
        <img v-for="url in image.urlArr" :src="url" width="100">
        <a href="javascript:void(0)" @click="del(image.id)">删除</a>
    </div>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
   let v = new Vue({
     el:"body>div",
     data:{
        arr:[]
     },
       created:function () {
           axios.get("/select").then(function (response) {
               v.arr = response.data;
               //遍历每个图片对象
               for (let image of v.arr) {
                   //给image对象添加一个数组的属性 里面装图片的路径
                   // /a.jpg,/b.jpg,/c.jpg     ["/a.jpg","/b.jpg","/c.jpg"]
                   image.urlArr = image.urls.split(",");
               }
           })
       },
       methods:{
         del(id){
             if (confirm("您确定删除吗?")){
                 axios.get("/delete?id="+id).then(function (response) {
                     location.reload();//刷新页面
                 })
             }
         }
       }
   })
</script>
</body>
</html>